<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!-- submit을 button으로 변경한다. -->
<script type="text/javascript" src="/hansot/jquery.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		selectchk();
	});

	function selectchk() {
		var category = document.getElementById("categoryId");
		var cateid = document.getElementById("category").value;
		var op = category.options;
		var len = category.length;
		var index = 0;
		for ( var i = 0; i < len; i++) {
			if (op[i].value == cateid) {
				index = i;
			}
		}
		category.selectedIndex = index;
	};
	function formCheck() {		
		var form = window.document.searchform;
		if (!form.name.value) {
			alert("이름을 넣으세요");
			form.name.focus();
			return false;
		}
	}
</script>
<h2>상품 검색 및 수정, 삭제</h2><font color="red" size="2">${requestScope.message }</font><br>
<p>
<form name="searchform" action="/hansot/menuSearch.do" onsubmit="return formCheck()">
	이름 : <input type="text" name="name" id="name"> <input
		type="submit" value="검색" /> <input type="reset" value="재입력" />
</form>
<hr>
<form name="modifyform" action="/hansot/menuModify.do">
	<table width="550" border="1">
		<c:forEach items="${requestScope.menu_list }" var="menuto">
			<tr>
				<td align="center">메뉴ID :</td>
				<td><input type="text" id="menuId" name="menuId"
					value="${menuto.menuId }"></td>
			</tr>
			<tr>
				<td align="center">메뉴이름 :</td>
				<td><input type="text" name="menuName"
					value="${menuto.menuName }"></td>
			</tr>
			<tr>
				<td align="center">메뉴가격 :</td>
				<td><input type="text" name="menuPrice"
					value="${menuto.menuPrice }"></td>
			</tr>
			<tr>
				<td align="center">이미지 주소 :</td>
				<td><input type="text" name="imgLocation"
					value="${menuto.imgLocation}"></td>
			</tr>
			<tr>
				<td align="center">category_id :</td>
				<td><select id="categoryId" name="categoryId">
						<option value="category-01">category-01</option>
						<option value="category-02">category-02</option>
						<option value="category-03">category-03</option>
						<option value="category-04">category-04</option>
						<option value="category-05">category-05</option>
						<option value="category-06">category-06</option>
						<option value="category-07">category-07</option>
						<option value="category-08">category-08</option>
				</select></td>
				<input type="hidden" id="category" value="${menuto.categoryId}">
			</tr>
			<tr>
				<td align="center">제품 설명 :</td>
				<td><input type="text" name="explanation"
					value="${menuto.explanation }"></td>
			</tr>
		</c:forEach>
	</table>
	<input type="submit" value="수정" />
</form>
<form action="/hansot/menuDelete.do">
	<c:forEach items="${requestScope.menu_list }" var="menuto">
		<a href="/hansot/menuDelete.do?menuId=${menuto.menuId }"><input type="button" value="삭제"></a>
	</c:forEach>
</form>










